/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.input;

import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import net.worlds.Main;
import net.worlds.ui.UI;


public class XMouseListener implements MouseListener{

    public void mouseClicked(MouseEvent e) {
    }

    public void mousePressed(MouseEvent e) {
        InputState.lastMouseButton = InputState.mouseButton;
        InputState.mouseButton = e.getButton();
        InputState.mouseClickX = InputState.mouseX;
        InputState.mouseClickY = InputState.mouseY;
        Main.requestFocus();
    }

    public void mouseReleased(MouseEvent e) {
        if(e.getButton() == InputState.lastMouseButton)
            InputState.mouseButton = 0;
        else
            InputState.mouseButton = InputState.lastMouseButton;
    }

    public void mouseEntered(MouseEvent e) {
        if(!InputState.pressedKeyCodes.contains(KeyEvent.VK_SHIFT))
            UI.shiftPressed = false;
        UI.mouseInside = true;
    }

    public void mouseExited(MouseEvent e) {
        UI.mouseInside = false;
        if(Main.getOverlay() != null)
            Main.getOverlay().setMouseComponent(null);
    }

}
